package com.pactera.madp.cp.service.sync;

import com.pactera.madp.cp.api.entity.sync.MaTotalDataBoardEntity;
import com.pactera.madp.cp.api.entity.sync.SyncEventEntity;

import java.util.List;

/**
 * @title 神策平台-请求神策API-服务接口定义
 * @date 2022-05-11
 * @author Deming.Chang
 */
public interface SaClientService {

    /**
     * 神策平台-API-响应数据格式
     */
    String SA_RESULT_JSON = "json";

    /**
     * SQL占位符
     */
    String SA_PLACEHOLDER = "?";

    /**
     * 神策平台-采集事件-SQL
     */
    String SA_EVENTS_SQL =
            "SELECT * FROM events e " +
            "WHERE e.$receive_time > ? " +
            "AND e.platform_type = '企业微信' " +
            "AND e.event IN ('EnterShop','MgrDetailView','ShareShop','FinancialView','FinancialBuyClick'," +
                    "'DepositView','DepositInClick','LoanView','LoanApplyClick','CreditView','CreditApplyClick'," +
                    "'DailyDetailView','ViewActivityDetail','JoinActivity','InfoDetailView','$WebPageLeave')";

    /**
     * 神策平台-访客浏览数据日期汇总数据-SQL
     */
    String SA_TOTALS_SQL = "SELECT e.recommend_id RECOMMEND_ID," +
            "COUNT(DISTINCT(e.distinct_id)) TOTAL_VISITORS," +
            "COUNT(1) TOTAL_BROWSES " +
            "FROM events e " +
            "WHERE e.recommend_id != '' " +
            "AND e.platform_type = '企业微信' " +
            "AND e.event IN ('EnterShop','MgrDetailView','ShareShop','FinancialView','FinancialBuyClick'," +
            "'DepositView','DepositInClick','LoanView','LoanApplyClick','CreditView','CreditApplyClick'," +
            "'DailyDetailView','ViewActivityDetail','JoinActivity','InfoDetailView','$WebPageLeave') " +
            "GROUP BY e.recommend_id";

    /**
     * 通过自定义查询接口获取采集事件列表数据
     * @param lastMaxReceiveTime 上一次最大接收时间
     * @return          采集事件列表
     */
    List<SyncEventEntity> getSaEvents(Long lastMaxReceiveTime);

    /**
     * 通过自定义查询接口获取访客浏览数据
     * @return          访客浏览数据
     */
    List<MaTotalDataBoardEntity> getSaDataBoardTotals();

}
